/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import { Form, Input, Radio, Select, Switch, Button, Tooltip, DatePicker } from 'antd';
import request from '@/utils/request';
import { connect } from 'dva';
import moment from 'moment';
const FormItem = Form.Item;
const { TextArea } = Input;

const RadioGroup = Radio.Group;
const Option = Select.Option;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      all_roles:[],
      level:0,
    };
  }
  componentDidMount() {
    const that=this;
  }
  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 7},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 15},
      }
    };

    const {getFieldDecorator} = this.props.form;
    return (
      <div>
        <Form onSubmit={this.handleSubmit}>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
                账号名称
            </span>
            )}
          >
            {getFieldDecorator('username', {
              initialValue: this.props.editRecord ? this.props.editRecord.username : '',
              rules: [{ required: true, message: '请输入名称' }],
            })(
              <Input disabled={Boolean(this.props.editRecord)}/>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
                有效期
            </span>
            )}
            help={'空表示无时间限制'}
          >
            {getFieldDecorator('valid_time', {
              initialValue: (this.props.editRecord&&this.props.editRecord.valid_time) ? moment(this.props.editRecord.valid_time) :'',
            })(
              <DatePicker style={{width:'100%'}} showTime={true}/>
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
                新密码
            </span>
            )}
          >
            {getFieldDecorator('new_password', {
              initialValue: '',
              rules: [{ required: true, message: '请输入新密码' }],
            })(
              <Input/>
            )}
          </FormItem>

        </Form>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);


